<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>博客</title>
    <link href="<%=basePath%>bootstrap/css/blog-home.css"/>
    <link href="<%=basePath%>bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <script src="<%=basePath%>bootstrap/js/jquery-2.1.1.js"></script>
</head>
<c:if test="${null!=admin}">
<div class="container">
    <!-- Sidebar -->
    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="<%=basePath %>admin?method=index">博客管理系统</a>
        </div>
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse navbar-ex1-collapse">
            <ul class="nav navbar-nav side-nav">
                <li><a href="<%=basePath %>admin?method=index"><i class="glyphicon glyphicon-dashboard"></i> 控制面板</a></li>
                <li><a href="<%=basePath %>admin?method=useradmin"><i class="glyphicon glyphicon-cog"></i> 用户管理</a></li>
                <li><a href="<%=basePath %>admin?method=SysArticalAdmin"><i class="glyphicon glyphicon-cog"></i> 文章管理</a></li>
                <li class="active"><a href="<%=basePath %>admin?method=SysCategoryAdmin"><i class="glyphicon glyphicon-edit"></i> 分类管理</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right navbar-user">
                <li><a href="#"><i class="glyphicon glyphicon-user"></i>${admin.userName}</a></li>
                <li><a href="<%=basePath%>admin?method=logout"><i class="glyphicon glyphicon-off"></i> 登出</a></li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </nav>
    <div id="page-wrapper">
        <div class="row">
            <div class="col-md-12">
                <br>
                <ol class="breadcrumb">
                    <li><a href="<%=basePath%>admin/admin.jsp"><i class="glyphicon glyphicon-dashboard"></i> 控制面板</a></li>
                    <li class="active"><i class="glyphicon glyphicon-cog"></i> 分类管理</li>
                </ol>
                <p><a class="btn btn-primary" href="<%=basePath %>admin/AddSysCategory.jsp">新建分类</a><p>
                 <c:if test="${null != succDeleScg}">
                <div class="row">
                    <div class="col-md-12">
                        <div class="alert alert-success">${succDeleScg}</div>
                    </div>
                </div>
                <%
                        request.getSession().removeAttribute("succDeleScg");
                %>
                 </c:if>

                <c:if test="${null != errorDeleScg}">	<%-- 删除失败 --%>
                <div class="row">
                    <div class="col-md-12">
                        <div class="alert alert-error">${errorDeleScg}</div>
                    </div>
                </div>
                <%
                        request.getSession().removeAttribute("errorDeleScg");
                %>
                </c:if>
                <c:if test="${null != succAddScg}">	<%-- 添加成功 --%>
                <div class="row">
                    <div class="col-md-12">
                        <div class="alert alert-success">${succAddScg}</div>
                    </div>
                </div>
                <%
                        request.getSession().removeAttribute("succAddScg");
                %>
                </c:if>
                <c:if test="${null != errorAddScg}">	<%-- 添加失败 --%>
                <div class="row">
                    <div class="col-md-12">
                        <div class="alert alert-error">${errorAddScg}</div>
                    </div>
                </div>
                <%
                        request.getSession().removeAttribute("errorAddScg");
                %>
                </c:if>
                <c:if test="${null != succUpdateScg}">		<%-- 更新成功 --%>
                <div class="row">
                    <div class="col-md-12">
                        <div class="alert alert-success">${succUpdateScg}</div>
                    </div>
                </div>
                <%
                        request.getSession().removeAttribute("succUpdateScg");
                %>
                </c:if>
                <c:if test="${null != errorUpdateScg}">	<%-- 更新失败 --%>
                <div class="row">
                    <div class="col-md-12">
                        <div class="alert alert-error">${errorUpdateScg}</div>
                    </div>
                </div>
                <%
                        request.getSession().removeAttribute("errorUpdateScg");
                %>
                </c:if>
                <div class="row">
                    <div class="col-md-12">
                        <div class="table-responsive">
                            <table class="table table-hover tablesorter">
                                <thead>
                                <tr>
                                    <th>分类名</th>
                                    <th>文章数</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <c:if test="${scgList != null}">
                                    <c:forEach items="${scgList}" var="scg">
                                        <c:if test="${scg.isDelete==0}">
                                <%
                                    String deleUrl = basePath + "admin?method=DeleteSysCategory&scgId=${scg.id}";
                                %>
                                <tr>
                                    <td>${scg.categoryName}</td>
                                    <td>${scg.articles}</td>
                                    <td>	<c:if test="${无分类!=scg.categoryName}">
                                        <a href="<%=basePath %>admin?method=EditSysCategory&scgId=${scg.id}"><i class="glyphicon glyphicon-pencil"></i></a>
                                        <a onClick="dele('${deleUrl}')"><i class="icon-remove"></i></a>
                                        </c:if>
                                            <c:if test="${无分类==scg.categoryName}">
                                        <%="系统默认分类"%>
                                            </c:if>
                                    </td>
                                </tr>
                                        </c:if>
                                    </c:forEach>
                                </c:if>
                                <c:if test="${scgList == null}">
                                <%="获取分类失败"%>
                                </c:if>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div>
                    <!-- pager -->
                    <ul class="pager">
                        <c:if test="${curPage>1}">
                        <li class="previous"><a
                                href="<%=basePath%>admin?method=SysCategoryAdmin&curPage=${curPage-1}">&larr;
                            上一页</a></li>
                        </c:if>
                        <c:if test="${curPage<totalPages}">
                        <li class="next"><a
                                href="<%=basePath%>admin?method=SysCategoryAdmin&curPage=${curPage + 1}">下一页
                            &rarr;</a></li>
                        </c:if>
                    </ul>
                </div>
            </div>
        </div><!-- /.row -->
    </div><!-- /#page-wrapper -->
</div>
</c:if>
<c:if test="${null==admin}">
<%-- 404 page --%>
<jsp:include page="404.jsp"></jsp:include>
</c:if>
<script type="text/javascript">
    function dele(deleUrl) {
        if (confirm("你确定要删除该分类吗？")) {
            location.href = deleUrl;
        }
    }
</script>
<div><audio autoplay="autoplay" loop="true"><source src="music/1.mp3"></audio></div>
</body>
</html>
